//
//  SuperInputView.m
//  MyCloudMusic
//
//  Created by pub on 2024/6/11.
//

#import "SuperInputView.h"

@implementation SuperInputView

- (void)initViews{
    [super initViews];
    
    self.myWidth = MyLayoutSize.fill;
    self.myHeight = MyLayoutSize.wrap;
    
}

- (UIImageView *)iconView{
    if (!_iconView) {
        _iconView = [UIImageView new];
        _iconView.myWidth = 20;
        _iconView.myHeight = 20;
        _iconView.tintColor = [UIColor black66];
        _iconView.image = R.image.inputUsername;
        _iconView.visibility = MyVisibility_Gone;
    }
    
    return _iconView;
}


- (QMUITextField *)textFieldView{
    if (!_textFieldView) {
        _textFieldView = [QMUITextField new];
        _textFieldView.myWidth = MyLayoutSize.wrap;
        _textFieldView.myHeight = 46;
        _textFieldView.weight = 1;
        _textFieldView.placeholder = @"";
        _textFieldView.font = [UIFont systemFontOfSize:16];
        _textFieldView.clearButtonMode = UITextFieldViewModeWhileEditing;
        _textFieldView.autocapitalizationType = UITextAutocapitalizationTypeNone;
    }
    return _textFieldView;
}

- (void)smallRadius{
    self.layer.cornerRadius = SMALL_RADIUS;
    self.layer.borderWidth = 1;
    self.layer.borderColor = [UIColor colorDivider].CGColor;
    
    _container.paddingLeft = PADDING_MEDDLE;
    _container.paddingRight = PADDING_MEDDLE;
}

- (void)passwordStyle{
    _textFieldView.secureTextEntry = YES;
}

+  (SuperInputView *)withImage:(UIImage *)image placeHolder:(NSString *)placeHolder{
    SuperInputView *view = [SuperInputView new];
    
    [view initInputView];
    
    view.iconView.image = image;
    view.iconView.visibility = MyVisibility_Visible;
    view.textFieldView.placeholder = placeHolder;
    return view;
}

- (void)initInputView{
    _container = [[MyLinearLayout alloc] initWithOrientation:MyOrientation_Horz];
    _container.myHeight = MyLayoutSize.wrap;
    _container.myWidth = MyLayoutSize.fill;
    _container.subviewSpace = 5;
    _container.gravity = MyGravity_Vert_Center;
    
    [self addSubview:_container];
    [_container addSubview:self.iconView];
    [_container addSubview:self.textFieldView];
    
}

+ (SuperInputView *)withPlaceHolder:(NSString *)string{
    SuperInputView *view = [SuperInputView new];
    [view initInputView];
    view.textFieldView.placeholder = string;
    
    [view borderButtom];
    return view;
}

- (void)borderButtom{
    self.layer.borderColor = [UIColor black90].CGColor;
    self.qmui_borderPosition = QMUIViewBorderPositionBottom;
}

@end
